import { Injectable } from '@angular/core';
// import { API_URL } from '../const/base.const';
import { HttpService } from './http.service';
import { API_URL } from '../const/base.const';

@Injectable({
  providedIn: 'root',
})
export class FeatureScenarioService {
  constructor(private $http: HttpService) {}

  //根据fid查询下属的sid
  getSidsByFid(fid: number) {
    return this.$http.get(API_URL.FEATURE_SCENARIO + '/fid/' + fid);
  }

  //fid下关联多个sid
  createMany(fid: number, sids: number[]) {
    return this.$http.post(`${API_URL.FEATURE_SCENARIO}/createMany`, {
      fid,
      sids,
    });
  }

  remove(fid: number, sid: number) {
    return this.$http.delete(`${API_URL.FEATURE_SCENARIO}/${fid}/${sid}`);
  }

  //更新排序
  udpateSort(data: any[]) {
    return this.$http.post(`${API_URL.FEATURE_SCENARIO}/updateSort`, data);
  }

  // 创建feature和scenario的关联关系
  createOne(fid: number, sid: number, sort: number) {
    return this.$http.post(`${API_URL.FEATURE_SCENARIO}`, { fid, sid, sort });
  }
}
